<{include file="public_html/header.html"}>
<{include file="public_html/left_menu.html"}>
	<!-- content starts -->
	<blockquote class="layui-elem-quote"><{$action}></blockquote>

	<fieldset class="layui-elem-field">
  		<legend>按条件搜索</legend>
  		<div class="layui-field-box">
			<form class="layui-form layui-form-pane1" method="post" action="<{$current_url}>">
				<{assign var="pid" value=$conditions['pid']|default:"all"}>
				<div class="layui-form-item">
					<div class="layui-inline">
						<select name="pid" >
							<option value="all">按权限筛选</option>
							<option value="0" <{if $pid == 0 AND $pid != 'all'}>selected="selected"<{/if}>>顶级权限</option>
							<{foreach from=$privilege_list item=item}>
								<option value="<{$item->id}>" <{if $item->id == $pid}>selected="selected"<{/if}>><{$item->menu_title}></option>
							<{/foreach}>
					  	</select>
				  	</div>

					<div class="layui-inline">
			      		<input type="text" name="search" placeholder="权限名称" value="<{if isset($conditions['search']) AND $conditions['search']}><{$conditions['search']}><{/if}>" class="layui-input">
			    	</div>

			    	<div class="layui-inline">
			    		<button type="submit" class="layui-btn">搜索</button>
			    		<a class="layui-btn" href="/privilege/add"><i class="layui-icon"></i> 添加菜单</a>
			    	</div>
		    	</div>

				
			</form>
  		</div>
	</fieldset>
	<form class="layui-form layui-form-pane1" method="post" action="/privilege/update_sorts" delete_action="/privilege/delete">
		<table class="layui-table" lay-even lay-skin="row">
            <!-- <colgroup>
                <col />
                <col width="170" />
                <col width="200" />
                <col width="200" />
                <col width="300" />
                <col width="200" />
                <col width="120" />
                <col width="100" />
                <col width="125" />
            </colgroup> -->
		  	<thead>
			  	<tr>
				  	<th>ID</th>
				  	<th>父分类</th>
				  	<th>菜单名称</th>
				  	<th>控制器名称
				  		<{if $conditions['sort'] eq 1 and $conditions['asc_des'] eq 1}>
				  		<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/1/2/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="升序" class="icon icon-green icon-arrowthick-n"></span></a>
				  		<{else}>
						<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/1/1/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="降序" class="icon icon-green icon-arrowthick-s"></span></a>
						<{/if}>
				  	</th>
				  	<th>菜单URL
				  		<{if $conditions['sort'] eq 2 and $conditions['asc_des'] eq 1}>
				  		<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/2/2/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="升序" class="icon icon-green icon-arrowthick-n"></span></a>
				  		<{else}>
						<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/2/1/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="降序" class="icon icon-green icon-arrowthick-s"></span></a>
						<{/if}>
				  	</th>
				  	<th>添加日期
				  		<{if $conditions['sort'] eq 3 and $conditions['asc_des'] eq 1}>
				  		<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/3/2/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="升序" class="icon icon-green icon-arrowthick-n"></span></a>
				  		<{else}>
						<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/3/1/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="降序" class="icon icon-green icon-arrowthick-s"></span></a>
						<{/if}>
				  	</th>
				  	<th>是否显示
				  		<{if $conditions['sort'] eq 4 and $conditions['asc_des'] eq 1}>
				  		<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/4/2/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="升序" class="icon icon-green icon-arrowthick-n"></span></a>
				  		<{else}>
						<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/4/1/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="降序" class="icon icon-green icon-arrowthick-s"></span></a>
						<{/if}>
				  	</th>
				  	<th>排序
				  		<{if $conditions['sort'] eq 5 and $conditions['asc_des'] eq 1}>
				  		<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/5/2/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="升序" class="icon icon-green icon-arrowthick-n"></span></a>
				  		<{else}>
						<a href ="<{base_url()}>privilege/index/<{$conditions['pid']}>/5/1/<{$conditions['search']}>/<{$conditions['limit']}>"><span title="降序" class="icon icon-green icon-arrowthick-s"></span></a>
						<{/if}>
				  	</th>
				  	<th>操作</th>
			  	</tr>
		  	</thead>   
		  	<tbody>
		  	<{foreach from=$privilege_data item=item}>
			  	<tr>
			  		<td class="center"><input type="checkbox" name="ids[]" value="<{$item->id}>" title="<{$item->id}>"> </td>
			  		<td class="center"><{$item->pid}></td>
			  		<td class="center"><{$item->menu_title}></td>
			  		<td class="center"><{$item->action}></td>
			  		<td class="center"><{$item->menu_url}></td>
			  		<td class="center"><{$item->add_time|date_format:'%Y-%m-%d %H:%M:%S'}></td>
			  		<td class="center">
			  			<{if $item->status}>
			  			<a privilege_id="<{$item->id}>" status="0" class="activity_status" href="javascript:;">显示</a>
			  			<{else}>
			  			<a privilege_id="<{$item->id}>" status="1" class="activity_status" href="javascript:;">隐藏</a>
			  			<{/if}>
			  		</td>
			  		<td class="center"><input style="width:40px;" name="sort[<{$item->id}>]" maxlength="4" type="text" value="<{$item->sort}>" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" /></td>
			  		<td class="center">
						<a class="layui-btn layui-btn-primary layui-btn-small" href="/privilege/edit/<{$item->id}>" target="_blank"><i class="layui-icon"></i></a>
						<a class="layui-btn layui-btn-primary layui-btn-small delete_data" href="/privilege/delete/<{$item->id}>"><i class="layui-icon"></i></a>
					</td>
			  	</tr>
		  	<{/foreach}>
		  	<{if $privilege_data|count eq 0}>
		  		<tr>
			  		<td class="center" style=" height:120px; text-align:center;line-height:120px;" colspan="8">
						赞无数据！
					</td>
			  	</tr>
		  	<{/if}>
		  	<tr>
				<td class="center" colspan="13">
					<input type="checkbox" lay-filter="checkbox_all" title="全选">
					<button id="delete" class="layui-btn layui-btn-primary layui-btn-small" style="margin-top:4px;"><i class="layui-icon"></i> 批量删除</button>
				</td>
			</tr>
	  		</tbody>
	  	</table>
  	</form>
  	<div class="layui-box layui-laypage layui-laypage-default">
		<{$pagination}>
	</div>
<script>
	$(".activity_status").click(function(){
		var _this = $(this);
		var privilege_id = _this.attr("privilege_id");
		var status = _this.attr("status");
		$.ajax({
			type : "get",
			url : "/privilege/status/",
			data: {'id':privilege_id,'status':status},
			dataType:'json',
			success:function(data){
				if(data.code == 0) {
					if(status=='0') {
						_this.attr("status",1);
						_this.html('隐藏');
					}else{
						_this.attr("status",0);
						_this.html('显示');
					}
				}else {
					alert(data.msg);
				}
			}		
		});
	});
</script>
<{include file="public_html/footer.html"}>